package org.sbbs.entity;

import jakarta.persistence.MappedSuperclass;
import lombok.Data;
import lombok.EqualsAndHashCode;
//import org.springframework.data.annotation.CreatedBy;
//import org.springframework.data.annotation.CreatedDate;
//import org.springframework.data.annotation.LastModifiedBy;
//import org.springframework.data.annotation.LastModifiedDate;

import java.time.LocalDateTime;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;
import org.hibernate.envers.AuditOverride;

/**
 * <b>描述:</b><br/>
 * <br/>
 * <b>审计实体基类<b/><br/>
 * 同时使用SpringData和Hibernate两种审计机制<br/>
 * SpringData:定义数据项:@CreatedBy、@CreatedDate、@LastModifiedBy、@LastModifiedDate<br/>
 * Hibernate Envers: 在实体上加入注解:@Audited,如果需要继承父类内容:@AuditOverride(forClass =
 * BaseAuditEntity.class, isAudited = true) <br/>
 *
 * @see DemoBeanAuditManagerTest
 * <p>
 * <b>创建时间:</b> 2025年1月14日 12:39:51 <br/>
 * <b>作者:</b> Mr.FDC <fdc_messenger@126.com> <br/>
 * <p>
 * <b>修改记录:</b><br/>
 * <ol>
 * <li>......</li>
 * </ol>
 */
// @EntityListeners(AuditingEntityListener.class)
@Data
// 基于hibernate envers的审计备份
@AuditOverride(forClass = BaseEntity.class, isAudited = true)
@EqualsAndHashCode(callSuper = true)
@MappedSuperclass
public class BaseAuditEntity extends BaseEntity {

    @CreationTimestamp
    private LocalDateTime createTime;

    @UpdateTimestamp
    private LocalDateTime updateTime;

//	private LocalDateTime createTime;
//
//	private LocalDateTime lastUpdateTime;
//	@CreatedBy
//	private String createUser;
//
//	@LastModifiedBy
//	private String updateUser;
}
